
import React, { memo } from 'react'
import { Input,Button,Form,} from "antd"
import "./Addrole.css"
import axios from 'axios'
 let formRef=React.createRef()
function Addrole(props) {

   
    
    function onFinish(values) {
        console.log('Received values of form: ', values);
        axios({
            url: "http://localhost:3000/role",
            method: "post",
            data: values
        }).then(res => {
            props.onOk()
            console.log(res.data, "123");
           formRef.current.resetFields();
        });
    }
        return (
            <div>
                <Form
                   ref={formRef}
                    name="normal_login"
                    className="login-form"
                    style={{ display: props.show }}
              
                    onFinish={onFinish}
           
                >
                    <Form.Item
                        name="id"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your Username!',
                            },
                        ]}
                    >
                        <Input placeholder="请输入ID" />
                    </Form.Item>
                    <Form.Item
                        name="name"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your Password!',
                            },
                        ]}
                    >
                        <Input
                            placeholder="请输入部门名称"
                        />
                    </Form.Item>
                    <Form.Item
                        name="age"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your Password!',
                            },
                        ]}
                    >
                        <Input
                            placeholder="请输入部门代码"
                        />
                    </Form.Item>
           
                    <Form.Item
                        name="address"
                    >
                        <Input
                            placeholder="修改时间"
                        />
                    </Form.Item>
                    <Form.Item
                        name="tags"
                    >
                        <Input
                            placeholder="请输入修改人"
                        />
                    </Form.Item>
                    <Form.Item>
                        <Button type="primary" htmlType="submit" className="login-form-button">
                            添加
                        </Button>
 
                    </Form.Item>
                    <Form.Item>
                        <Button type="primary" className="login-form-button" onClick={props.edit}>
                            取消
                        </Button>
 
                    </Form.Item>
                </Form>
            </div>
        )
    
}
export default memo(Addrole) 